#include "myList.h"

namespace real 
{
    void test_list1()
    {
        list<int> l;
        l.push_back(1);
        l.push_back(2);
        l.push_back(3);
        l.push_back(4);
        l.push_back(5);
        l.push_back(6);
        l.insert(++(++l.begin()), 10);
        
        // typename list<int>::iterator start = l.begin();
        auto start = l.begin();
        while(start != l.end())
        {
            cout << (*start) << " ";
            // cout << (start->_pnode->_data) << " ";
            start++;
        }
        cout << endl;

        for(auto e: l)
        {
            cout << e << " ";
        }
        cout << endl;

        l.push_front(61);
        list<int>::const_iterator start2 = l.cbegin();
        // auto start2 = l.begin();
        while(start2 != l.cend())
        {
            // cout << ((*start2)++) << " ";
            cout << (*start2) << " ";
            // cout << (start->_pnode->_data) << " ";
            ++start2;
        }
        cout << endl;
    }

    void test_list2()
    {
        list<std::string>s;
        s.push_front("ab");
        s.push_front("bc");
        s.push_front("cd");
        s.push_front("de");

        list<std::string>s2;
        s2 = s; // 赋值

        print_iterator(s);
        s.pop_front();
        print_iterator(s);
        s.pop_back();
        print_iterator(s);

        print_iterator(s2);
        s2.insert(--s2.end(), "100");
        print_iterator(s2);

    }

     void test_list3()
    {
        list<std::string>s;
        s.push_back("ab");
        s.push_back("bc");
        s.push_back("cd");
        s.push_back("de");
        list<std::string>s2=s;
        print_iterator(s2);
    }
}

int main()
{
    // real::test_list1();
    // real::test_list2();
    real::test_list3();
    return 0;
}